package bb.lanxing.model.json;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.Date;

public class LatestLocation implements Parcelable {
    public static final Creator<LatestLocation> CREATOR = new Creator<>() {
        @Override
        public LatestLocation createFromParcel(Parcel parcel) {
            return new LatestLocation(parcel);
        }

        @Override
        public LatestLocation[] newArray(int i) {
            return new LatestLocation[i];
        }
    };
    private Date dateTime;
    private double latitude;
    private double longitude;
    private ServerUser serverUser;
    private double speed;
    private int status;

    @Override
    public int describeContents() {
        return 0;
    }

    public ServerUser getServerUser() {
        return this.serverUser;
    }

    public double getLatitude() {
        return this.latitude;
    }

    public void setLatitude(double d) {
        this.latitude = d;
    }

    public double getLongitude() {
        return this.longitude;
    }

    public void setLongitude(double d) {
        this.longitude = d;
    }

    public double getSpeed() {
        return this.speed;
    }

    public void setSpeed(double d) {
        this.speed = d;
    }

    public int getStatus() {
        return this.status;
    }

    public void setStatus(int i) {
        this.status = i;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeParcelable(this.serverUser, i);
        parcel.writeDouble(this.latitude);
        parcel.writeDouble(this.longitude);
        Date date = this.dateTime;
        parcel.writeLong(date != null ? date.getTime() : -1L);
        parcel.writeDouble(this.speed);
        parcel.writeInt(this.status);
    }

    protected LatestLocation(Parcel parcel) {
        this.serverUser = parcel.readParcelable(ServerUser.class.getClassLoader());
        this.latitude = parcel.readDouble();
        this.longitude = parcel.readDouble();
        long readLong = parcel.readLong();
        this.dateTime = readLong == -1 ? null : new Date(readLong);
        this.speed = parcel.readDouble();
        this.status = parcel.readInt();
    }
}